<?php

namespace App\Admin\Actions\Player;

use App\Models\Player;
use Dcat\Admin\Actions\Response;
use Dcat\Admin\Grid\BatchAction;
use Illuminate\Http\Request;

class BatchUpgradePoster extends BatchAction
{
    protected string $title = '批量更新海报';

    public function handle(Request $request): Response
    {
        foreach ((array) $this->getKey() as $key) {
            $player = Player::ofAdmin()->find($key);
            $player->updatePoster();
        }

        return $this->response()->success('批量更新任务已提交')->refresh();
    }

    public function confirm(): array
    {
        return [
            '批量更新海报',
            '任务提交后，请稍候查看海报',
        ];
    }
}
